from coin.exchange.base.order_gateway import OrderSide


def order_logger(func):
  def wrapper(self, product, price, qty, order_side):
    assert order_side in (OrderSide.BUY, OrderSide.SELL), \
      'Unknown order side: %s' % order_side
    func(self, product, price, qty, order_side)
    if order_side == OrderSide.BUY:
      order_side = 'BUY'
    elif order_side == OrderSide.SELL:
      order_side = 'SELL'
    else:
      order_side = 'UNKNOWN'
    self.logger.info('%s %s %s @ %s', order_side, product, qty, price)

  return wrapper
